CXXFLAGS =	-O0 -g -std=c++0x -fmessage-length=0 -DFREEGLUT_STATIC -DGLEW_STATIC -ggdb -DDEBUG -fno-inline -rdynamic

SRCDIR = src

HEADERS = $(wildcard $(SRCDIR)/*.h)

OBJS = $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/figures/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/debug/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/glUtils/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/deformacion/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/curvas/*.cpp))

LIBS = -lGLEW -lGLU -lGL -lglut -lSOIL

TARGET = tpEdificio debugInteractivo debugNormales debugLight shadertest

.DEFAULT_GOAL = all

#$(addprefix %,$(addsuffix .o,$(TARGET))): $(OBJS)
#	$(CXX) -c -o $(@) $(filter %$(@).o,$(OBJS)) $(LIBS)

# MMM no tendria que estar andando sin el filter-out
$(TARGET): $(filter %$(@).o,$(OBJS)) $(filter-out $(addprefix %,$(addsuffix .o,$(TARGET))),$(OBJS)) $(HEADERS)
#	@echo $(HEADERS)
#	@echo $(OBJS)
#	@echo
#	@echo $(addprefix %,$(addsuffix .o,$(TARGET)))
#	@echo
#	@echo $(filter-out $(addprefix %,$(addsuffix .o,$(TARGET))),$(OBJS))
#	@echo
#	@echo $(filter %$(@).o,$(OBJS))
	$(CXX) -o $@ $(filter-out $(addprefix %,$(addsuffix .o,$(TARGET))),$(OBJS)) $(filter %$(@).o,$(OBJS)) $(LIBS)

all: $(TARGET)

clean:
	rm -f $(OBJS) $(TARGET)
